<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // JSON对象 字符串 --->  JS对象
        /*
        值的类型
        1 数值
        2 字符串
        3 布尔值
        4 JSON数组
        5 JSON对象
        6 null
        */
        var j = `{
            "id":1,
            "name":"sam",
            "marry":true,
            "son":{
                "name":"vilia",
                "age":10
            }
            "hobby":["eat","刷剧"]
        }`;
        console.log(j);
        var p = JSON.parse(j);//JSON对象字符串 解析为 JS对象
        console.log(p);
        for (k in p) {
            if (Array.isArray(p[k])) {
                p[k].forEach(ele => {
                    console.log(ele);
                });
            }
        }

    </script>
</body>

</html>